InstancingΒΆ

It is possible to instanciate objects in the scene using the RenderGraph, such as simple primitives, lights and more complex hierarchies.

Instancing Objects

It is possible to add primitives directly using the RenderGraph.

Add a cube to the root of the scene

In the RenderGraph view:

  1. Press Ctrl+Space to open the node picker
  2. Enter Cube
  3. Connect the Cube node to the graph

Instancing a simple cube at the root.

Add a cube as a child of another node

In the RenderGraph view:

  1. Press Ctrl+Space to open the node picker
  2. Enter Cube
  3. Connect the Cube node to the graph
  4. Connect a Path node to the Parent input

When parented to multiple nodes, the primitive will be instanced multiple times.

The cube is now instanciated as the child of Node%d nodes. The child transform naturally inherits its parent.

Instancing Scene Graph Nodes

More generally, you can instanciate scene hierarchies using the RenderGraph SceneGraph node.

Add an empty node at the root of the scene

In the RenderGraph view:

  1. Press Ctrl+Space to open the node picker
  2. Enter SceneGraph
  3. Connect the SceneGraph node to the graph

You can proceed to add new nodes to the hierarchy by double-clicking into the SceneGraph node. This hierarchy can be freely parented to another or multiple other scene nodes, using the Parent input.

Instancing Lights

Similarly, you can spawn lights directly using the RenderGraph. This is an alternative to creating lights directly in the scene graph, and is a convenient way to pack a lighting setup into a single RenderGraph.

This is useful to add a light as part of an asset look development, for instance to instanciate a light in all lamp posts of a scene.

Create a light in the RenderGraph

In the RenderGraph view:

  1. Press Ctrl+Space to open the node picker
  2. Enter a light name from the library ("PointLight", for instance)
  3. Press Enter

When connected to the graph, the light will be added to the scene. When provided a Parent, the light may be instanciated multiple times in the scene. Without parenting, the light is added to the root of the scene.

The light is connected to the graph, without parent, resulting in a single light instanciated at the root of the scene.

The light is connected to the graph, parented to the cubes, resulting in the light instanciated above all cubes.

Instancing Scene Graph pieces

It is possible to enrich the scene graph using the render graph by spawning scene nodes. For instance, you can create instances of a part of the scene graph using the RenderGraph/Spawn node.

The Spawn node adds a piece of scene graph to the root of the scene.

The Spawn > Spawn Child indicates the path of the node to spawn.

Create an instance of a node at the root level

In the RenderGraph view:

  1. Press Ctrl+Space to open the node picker
  2. Enter Spawn and select the SpawnNode
  3. Set the Spawn > Spawn Child attribute to the path of the child node to spawn.

Connect RenderGraph inputs to the Parent input to specify at which point of the scene graph the child will be spawned. This allows you to to instanciate the node in different locations.

The ^RootNode%d*$ path expression is the Spawn parent.

Resulting in the HiddenRoot|Sphere being instanciated in 5 different locations.

When left unconnected, the Parent input of the Spawn node will spaw the child directly at the root of the scene.

Create an instance of a node at a specific location

In the RenderGraph view:

  1. Press Ctrl+Space to open the node picker
  2. Enter Spawn and select the Spawn node
  3. Set the Spawn > Spawn Child attribute to the path of the child node to spawn.
  4. Drag and drop the instance location into the RenderGraph, and connect the Path node to the Parent input.
If the spawning location contains children, the Spawn node will create an instance at each child location, resulting in the instance being duplicated. Make sure that the Path node contains a '$' character to avoid unwanted duplications. Inspecting the real Scene Graph

In the Node List, click the Toggle Live SceneGraph to display the scene graph with spawned nodes. In this mode, only SceneGraph nodes are displayed, and the nodes can not be moved or reparented.

The Node List displays the live scene graph, with PointLight instanciated as many times as there are cubes.